package cn.com.pansky.action.myaccount;

import net.vsame.url2sql.action.CommonAction;
import net.vsame.url2sql.helper.SqlHelper;
import cn.com.pansky.action.logs.Log;
import cn.com.pansky.util.MD5Util;

public class AccountSafeAction extends CommonAction {
	private Log log = new Log();

	public void updatePass(){
		//日志记录start
		String AF001 = log.start(" ", "UM");
		
		String findUser = urlConfig.getVar("findUser");
		String findPass = urlConfig.getVar("findPass");
		String updatePass = urlConfig.getVar("updatePass");
		
		String AA032 = user.getString("AA032");
		String AA001 = SqlHelper.queryOne(findUser, AA032).getString("AA001");
		
		String AA002 = MD5Util.string2MD5(context.getParam("AA002"));
		String AA002_1 = MD5Util.string2MD5(context.getParam("AA002_1"));
		
		if (AA002.equals(SqlHelper.queryOne(findPass, AA001).getString("AA002"))) {
			SqlHelper.execute(updatePass, AA002_1,AA001);
			datas.put("isPass", true);
			datas.put("info", "修改成功，请重新登陆");
		}else{
			datas.put("isPass", false);
			datas.put("info", "原密码输入错误");
		}
		//日志记录end
		boolean result = log.end(AF001, datas.get("isPass"), datas.get("info"));
		System.out.println("日志：修改密码"+result);

		context.getDatas().put("result", datas);
	}
}
